<template>
  <div class="wrapper">
    <h1>
      {{ formData.reportName }}
    </h1>
    <div class="title">
      <div>{{ formData.createDeptName }}</div>
      <div>{{ formData.reportTime }}</div>
    </div>
    <div>
      <!-- <el-form ref="form" :model="form" label-position="top" class="form" :show-message="false">
        <el-form-item :label="item.label" v-for="(item,index) in logFormConfin" :key="index">
          <div class="form-text">{{ form[item.formItem[0].prop] }}</div>
        </el-form-item>
      </el-form> -->
      <component :is="dutyType" :type="false" ref="dutyForm"></component>
    </div>
    <AccessoryTable ref="AccessoryTable" />
    <div style="padding-top: 20px;">
      <el-descriptions :labelStyle="{
        display: 'inline-block',
        textAlign: 'right',
        width: '100px',
        fontSize: '18px',
      }" :contentStyle="{ fontSize: '18px' }">
        <el-descriptions-item label="值班长">{{ formData.approvalUser }}</el-descriptions-item>
        <el-descriptions-item label="值班员">{{ formData.creator }}</el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>
<script>
import AccessoryTable from "../dutyRinght/accessoryTable.vue";
import DutyLog from "../dutyRinght/dutyLog.vue";
import DutyDaily from "../dutyRinght/dutyDaily.vue";
export default {
  name: "PreviewDialog",

  props: {
    previewData: {
      type: Object,
      default: () => {
        return {};
      }
    },
    dutyType: {
      type: String,
      default: "DutyLog" // 1日报  2日志
    }
  },
  components: {
    AccessoryTable,
    DutyLog,
    DutyDaily
  },
  data() {
    return {
      formData: {
        reportName: "",
        createDeptName: "",
        reportTime: "",
        approvalUser: "",
        creator: ""
      }
    };
  },
  watch: {
    previewData: {
      handler(val) {
        if (val) {
          this.formData = {
            reportName: val.reportName,
            createDeptName: val.createDeptName,
            reportTime: val.reportTime,
            approvalUser: val.approvalUser,
            creator: val.creator
          };
          this.$nextTick(() => {
            this.$refs.dutyForm.form = val;
          });
        }
      },
      immediate: true
    }
  }
};
</script>
<style lang="less" scoped>
.wrapper {
  h1 {
    text-align: center;
  }

  .title {
    line-height: 60px;
    display: flex;
    font-size: 20px;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;

    >div {
      width: 50%;
      border: 1px solid #797979;
      padding: 0 1rem;
    }

    >div:nth-child(2) {
      text-align: right;
    }
  }
}

.el-form {
  margin: 20px 10px 0;

  :deep(.el-form-item__label) {
    line-height: 30px;
    font-size: 18px;
    font-weight: 700;
  }

  :deep(.el-form-item__content) {
    line-height: 20px;
    font-size: 18px;
    text-indent: 1em;
  }
}

:deep(.table-title) {
  font-size: 18px;
}

.form-text {
  margin-left: 25px;
}
</style>
